﻿// Copyright (c) 2013, Simon Carter.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted 
// provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of 
//   conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice, this list of 
//  conditions and the following disclaimer in the documentation and/or other materials provided 
//  with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// History
// Initial Release - Simon Carter
//

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace ErrorManager.ErrorClient
{
    /// <summary>
    /// Display Options for Error Handling Form
    /// </summary>
    public sealed class DisplayOptions
    {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="allowContinue">Determines whether users can continue executing code or not</param>
        /// <param name="forceSendData">Determines whether crash data is automatically sent to the server without user interaction</param>
        /// <param name="formIcon">Icon to be displayed in the form</param>
        /// <param name="stayOnTop">Forces the error form to stay on top or other forms</param>
        /// <param name="title">Form title</param>
        public DisplayOptions(bool allowContinue = true, bool forceSendData = true, Icon formIcon = null, 
            bool stayOnTop = false, string title = "")
        {
            AllowContinue = allowContinue;
            ForceSendData = forceSendData;
            FormIcon = formIcon;
            FormOnTop = stayOnTop;
            Title = title;
        }

        /// <summary>
        /// Determines whether crash data is automatically sent to the server without user interaction
        /// </summary>
        public bool ForceSendData { get; set; }

        /// <summary>
        /// Form title
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// Determines whether users can continue executing code or not
        /// </summary>
        public bool AllowContinue { get; set; }

        /// <summary>
        /// Icon to be displayed in the form
        /// </summary>
        public Icon FormIcon { get; set; }

        /// <summary>
        /// Forces the error form to stay on top
        /// </summary>
        public bool FormOnTop { get; set; }
    }

    /// <summary>
    /// Connection Options for Error Handler
    /// </summary>
    public sealed class Options
    {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="host">IP Address of Error Server</param>
        /// <param name="port">Port to connect to</param>
        /// <param name="username">Username of user connecting</param>
        /// <param name="password">Password of user connecting</param>
        /// <param name="connectTimeout">Time out limit in seconds for connecting</param>
        /// <param name="fileSendTimeout">Time out limit in seconds for sending files</param>
        public Options(string host, int port, string username, string password, int connectTimeout = 30, int fileSendTimeout = 60)
        {
            Host = host;
            Port = port;
            Username = username;
            Password = password;
            ConnectTimeout = connectTimeout;
            FileSendTimeout = fileSendTimeout;
            IncludeSystemInformation = false;
        }

        /// <summary>
        /// Host server
        /// 
        /// Provide IP Address of host server
        /// </summary>
        public string Host { get; set; }

        /// <summary>
        /// Port connecting to
        /// </summary>
        public int Port { get; set; }

        /// <summary>
        /// Users name
        /// </summary>
        public string Username { get; set; }

        /// <summary>
        /// Users Password
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// Connection time out limit in seconds
        /// </summary>
        public int ConnectTimeout { get; set; }

        /// <summary>
        /// File send time out limit in seconds
        /// </summary>
        public int FileSendTimeout { get; set; }

        /// <summary>
        /// Determines whether to send system informtion
        /// </summary>
        public bool IncludeSystemInformation { get; set; }
    }
}
